﻿using System;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.ServiceLocation;

namespace UnityExtensions
{
    /// <summary>
    /// Argument class used by the <see cref="IScopedRegionViewRegistry.ContentRegistered" /> event when new content is registered.
    /// </summary>
    public class ViewRegisteredEventArgs : EventArgs
    {
        private readonly string _regionName;
        private readonly Func<IRegion, IServiceLocator, object> _resolveView;

        /// <summary>
        /// Initialises a new instance of <see cref="ViewRegisteredEventArgs"/>.
        /// </summary>
        /// <param name="regionName">The region name to which the content was registered.</param>
        /// <param name="resolveView">A delegate used to resolve the content which was registered.</param>
        public ViewRegisteredEventArgs(string regionName, Func<IRegion, IServiceLocator, object> resolveView)
        {
            _regionName = regionName;
            _resolveView = resolveView;
        }

        /// <summary>
        /// Gets the region name to which the content was registered.
        /// </summary>
        public string RegionName
        {
            get
            {
                return _regionName;
            }
        }

        /// <summary>
        /// Gets a delegate used to resolve the content which was registered.
        /// </summary>
        public Func<IRegion, IServiceLocator, object> ResolveView
        {
            get
            {
                return _resolveView;
            }
        }
    }
}
